from pyim.auth import login_required
from pyim.handler import BaseHandler
from pyim.packet import Packet
from pyim.user import User


class Handler(BaseHandler):
    @login_required
    def handle(self, connection, packet):
        # 获取在线用户
        reply = Packet()
        reply["command"] = packet["command"]
        reply["id"] = packet["id"]
        reply["user_list"] = User.manager.get_users(exclude=(connection.user.username, "*"))
        connection.route(reply)
